Bubble Sort Demo
Type names (or numbers) in the text box,
then press enter to add data to the list.
To sort, click [Start at Top]
and then [Compare Names] or
[Compare Numbers] several times.
Continue until the list is sorted.
The Bubble Sort algorithm is described below.
New Name
Sorting
Bubble Sort Algorithm
The concept behind the Bubble Sort Algorithm is quite simple.
Start at the top of the list and compare the 1st and 2nd items.
If the first item is "bigger" (belongs after) the 2nd item,
then swap (exchange) the items. Then move on to the 2nd and 3rd items.
Continue down the list, comparing neighbors, and swap whenever
the items are out of order. At the end of the list, return to the top
and go through the entire list again. If you get all the way through
the list without swapping anything, then the algorithm is finished.
You can try the demo above using various sets of data.
You will probably discover that in the worst-case-scenario -
when the list of items starts out backward - then the algorithm
requires N passes to finish. That is, if there are 10 items in the list,
then it must go through the list 10 times before it is finished.
Type names (or numbers) in the text box,
then press enter to add data to the list.
To sort, click [Start at Top]
and then [Compare Names] or
[Compare Numbers] several times.
Continue until the list is sorted.
The Bubble Sort algorithm is described below.
Sorting
The concept behind the Bubble Sort Algorithm is quite simple.
Start at the top of the list and compare the 1st and 2nd items.
If the first item is "bigger" (belongs after) the 2nd item,
then swap (exchange) the items. Then move on to the 2nd and 3rd items.
Continue down the list, comparing neighbors, and swap whenever
the items are out of order. At the end of the list, return to the top
and go through the entire list again. If you get all the way through
the list without swapping anything, then the algorithm is finished.
You can try the demo above using various sets of data.
You will probably discover that in the worst-case-scenario -
when the list of items starts out backward - then the algorithm
requires N passes to finish. That is, if there are 10 items in the list,
then it must go through the list 10 times before it is finished.
You can see demos of sorting algorithms here :
http://www.solidware.com/sort/